"""
tire.py --                                                                                            
                                                                                                                                                                                                        
It sets a tire's geometric properties.                                              
                                                                                                                                                                                                            
Date of creation: 2007-03-17                                                                        
                                                                                                                                                                                                
Copyright  Robotics and Automation Group, Pontificia Universidad Javeriana - Cali.                  
    Freddy Naranjo Perez, fnaranjo@puj.edu.co                                                                   
    Antonio Alejandro Matta Gomez amatta@puj.edu.co                                      
    Julian David Colorado, jdcolorado@puj.edu.co                           
    Juan Camilo Acosta Mejia, jcacosta@puj.edu.co                                    
                                                                                                                                                                                                        
See the file "license.terms" for information on usage and redistribution of this file, and for a    
DISCLAIMER OF ALL WARRANTIES.
"""

import vtk
from vtk.util.colors import *

class Tire:
  def __init__( self, ren, geomdim, posorient, bigcolor, smallcolor ):
        """ Inits a tire's figure and its associated texture"""
        
        self.bigtire = vtk.vtkCylinderSource()
        self.bigtire.SetHeight( geomdim[0] )
        self.bigtire.SetRadius( geomdim[1] )	
        self.bigtire.SetResolution(40)
        self.bigtireMapper = vtk.vtkPolyDataMapper()
        self.bigtireMapper.SetInputConnection(self.bigtire.GetOutputPort())
        self.bigtireMapper.SetResolveCoincidentTopologyToPolygonOffset()
        self.bigtireActor = vtk.vtkActor()
        self.bigtireActor.SetMapper(self.bigtireMapper)
        self.bigtireActor.RotateX( posorient[3] )
        self.bigtireActor.AddPosition( posorient[0], posorient[1], posorient[2] )
        self.bigtireActor.GetProperty().SetInterpolationToGouraud()
        self.bigtireActor.GetProperty().SetDiffuseColor(bigcolor)
        self.bigtireActor.GetProperty().SetSpecular(.3)
        self.bigtireActor.GetProperty().SetSpecularPower(30)
        #self.tireActor.GetProperty().SetColor(0.2, 0.2, 0.2)
        
        self.smalltire = vtk.vtkCylinderSource()
        self.smalltire.SetHeight( geomdim[0]+0.001 )
        self.smalltire.SetRadius( geomdim[1]/2)	
        self.smalltire.SetResolution(40)
        self.smalltireMapper = vtk.vtkPolyDataMapper()
        self.smalltireMapper.SetInputConnection(self.smalltire.GetOutputPort())
        self.smalltireMapper.SetResolveCoincidentTopologyToPolygonOffset()
        self.smalltireActor = vtk.vtkActor()
        self.smalltireActor.SetMapper(self.smalltireMapper)
        self.smalltireActor.RotateX( posorient[3] )
        self.smalltireActor.AddPosition( posorient[0], posorient[1], posorient[2] )
        self.smalltireActor.GetProperty().SetInterpolationToGouraud()
        self.smalltireActor.GetProperty().SetDiffuseColor(smallcolor)
        self.smalltireActor.GetProperty().SetSpecular(.3)
        self.smalltireActor.GetProperty().SetSpecularPower(30)
        #self.tireActor.GetProperty().SetColor(0.2, 0.2, 0.2)
            
        #encapsulate everything into an assembly
        self.tireassembly = vtk.vtkAssembly()
        self.tireassembly.AddPart(self.bigtireActor)
        self.tireassembly.AddPart(self.smalltireActor)
        
        
    
        
    
    

        
        
            
        
    

    
  
  